package com.sfzlot.dev.netty.bean.bussiness;

/**
 * 产品类型
 * @author xieqi
 *
 */
public interface Product{
	public String getComment();
	public int getCode();
	
	/**智能家居**/
	enum SmartHome implements Product{
		POWERSWITCH(0x30); 	// 智能开关
		
	    @Override
		public int getCode() {
			return code;
		}

		private int code;
		SmartHome(int code){
	        this.code = code;
	    }

	    /**
	     * 根据code获取数据单元加密方式
	     * @param code
	     * @return
	     */
		public static SmartHome get(int code){
	        for (SmartHome bussinessIdentifier : SmartHome.values()) {
	            if (bussinessIdentifier.code == code) {
	                return bussinessIdentifier;
	            }
	        }
	        return null;
	    }
		
		 /**
	     * 根据码获取命令对应的备注
	     * 
	     */
	    @Override
		public String getComment(){
	    	switch (this) {
				case POWERSWITCH:
					return "智能开关";
			default:
				break;
	    	}
			return null;
	    }
    }
	
	/** 自助终端 **/
	enum SelfService implements Product{
		SCANBOX(0x30); 	// 扫码盒子
		
	    @Override
		public int getCode() {
			return code;
		}

		private int code;
		SelfService(int code){
	        this.code = code;
	    }

	    /**
	     * 根据code获取数据单元加密方式
	     * @param code
	     * @return
	     */
		public static SelfService get(int code){
	        for (SelfService bussinessIdentifier : SelfService.values()) {
	            if (bussinessIdentifier.code == code) {
	                return bussinessIdentifier;
	            }
	        }
	        return null;
	    }
		
		 /**
	     * 根据码获取命令对应的备注
	     * 
	     */
	    @Override
		public String getComment(){
	    	switch (this) {
				case SCANBOX:
					return "扫码盒子";
			default:
				break;
	    	}
			return null;
	    }
    }
	
	/** 智能广告 **/
	enum IntelligentAdv implements Product{
		ELABEL(0x20); 	// 电子标签
		
	    @Override
		public int getCode() {
			return code;
		}

		private int code;
		IntelligentAdv(int code){
	        this.code = code;
	    }

	    /**
	     * 根据code获取数据单元加密方式
	     * @param code
	     * @return
	     */
		public static IntelligentAdv get(int code){
	        for (IntelligentAdv bussinessIdentifier : IntelligentAdv.values()) {
	            if (bussinessIdentifier.code == code) {
	                return bussinessIdentifier;
	            }
	        }
	        return null;
	    }
		
		 /**
	     * 根据码获取命令对应的备注
	     * 
	     */
	    @Override
		public String getComment(){
	    	switch (this) {
				case ELABEL:
					return "电子标签";
			default:
				break;
	    	}
			return null;
	    }
    }
    
//    enum MainCourse implements Product {
//        LASAGNE, BURRITO, PAD_THAI,
//        LENTILS, HUMMOUS, VINDALOO;
//    }
//
//    enum Dessert implements Product {
//        TIRAMISU, GELATO, BLACK_FOREST_CAKE,
//        FRUIT, CREME_CARAMEL;
//    }
//
//    enum Coffee implements Product {
//        BLACK_COFFEE, DECAF_COFFEE, ESPRESSO,
//        LATTE, CAPPUCCINO, TEA, HERB_TEA;
//    }

//    public static void main(String[] args) {
//    	Product food = Product.SmartHome.POWERSWITCH;
//        System.out.println("==>"+food.getComment());
//    }
}
